<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4 class="modal-title" id="personModalLabel"><?php echo $pid ? "编辑" : "新增"; ?>商品</h4>
</div>
<div class="modal-body">
    <form id="product">
    <div class="form-group input-group  input-control">
        <input type="hidden" name="pid" id="pid" value="<?php echo $pid; ?>">
        <span class="input-group-addon">价格(0.00元)</span>
        <input type="text" class="form-control" placeholder="" name="price" id="price" value="<?php echo $price; ?>">
    </div>
    <div class="form-group input-group  input-control">
        <span class="input-group-addon">&nbsp;&nbsp;时长(分钟)</span>
        <input type="text" class="form-control" placeholder="" name="minute" id="minute" value="<?php echo $minute; ?>">
    </div>
    <span class="span-phone" id="psphonecheck"></span>
    </form>
</div>
<div class="modal-footer">
    <span class="tips" id="pstip"></span>
    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
    <button type="button" class="btn btn-primary" id="save">保存</button>
</div>
<script>
$(document).ready(function() {
    $('#save').click(function() {
        var price = $('#price');
        var minute = $('#minute');
        if (!price.val().trim()) {
            alert('请填写价格');
            price.focus();
            return;
        }

        if (!minute.val().trim()) {
            alert('请填写时长');
            minute.focus();
            return;
        }

        $.post("<?php echo APP_ADMIN_PATH; ?>/product/save",$('#product').serialize(),function(result){
            if(result.retcode == 2000000){
                alert(result.msg);
                refresh();
            }else{
                alert('发生错误，保存失败:'+result.retcode);
            }
        });
    });
});
</script>
